package cn.zymall.common.feign.fastFile;

import cn.zymall.common.config.feign.FeignSupportConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author xuxianda
 * @Description: 快速文件上传feign
 * @date 2020/8/23 10:19
 * @Copyright
 * @return
 **/

@FeignClient(name = "FASTFILE-WORK", configuration = FeignSupportConfig.class,path = "/upload")
public interface FastFileFeign {

    /**
     * 上传图片
     * @param file
     * @return 返回图片地址
     */
    @RequestMapping(method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public String uploadMethod(@RequestPart(value = "file") MultipartFile file);

    /**
     * 食用方式：
     *
     * 需要先在 propertie或yml中配置：
     *  eureka 必须要注册到 129.204.228.114:9002
     *
     *  导入依赖：
     *         <dependency>
     *             <groupId>org.springframework.cloud</groupId>
     *             <artifactId>spring-cloud-starter-openfeign</artifactId>
     *         </dependency>
     *
     *  yml配置feign：
     *  feign:
     *   hystrix:
     *     enabled: false
     *   client:
     *     config:
     *       default:
     *         connectTimeout: 10000  # 指定Feign连接提供者的超时时限
     *         readTimeout: 10000    # 指定Feign从请求到获取提供者响应的超时时限
     *   httpclient:
     *     connection-timeout: 10000
     *  然后使用@componentScan 扫描当前这个包
     *
     *  在你的类里 装载FastFileFeign
     *
     *     @Autowirde
     *     FastFileFeign fastFileFeign
     *
     *     调用fastFileFeign里的方法，传递参数，获取返回值
     */

}
